<?php
header("Content-type: text/html; charset=utf-8"); 
class page{
	public $content;
	public $title="Luhao's test web.";
	public $keywords="luhao,test,husband";
	public $button=array("home"=>"home.php",
						 "contact"=>"contact.php",
						 "service"=>"services.php",
						 "sitemap"=>"sitemap.php",
						 "news"=>"news.php",
						 "search"=>"search.php",
						 "release"=>"release.php",
						 "managebook"=>"managebook.php",
						 );
						 
	public function __set($name,$value){
		$this->attribute=$value;
		}//感觉这个可以省略
	public function display(){
		echo "<html>\n<head>\n";
		$this->displaytitle();
		$this->displaykeywords();
		$this->displaystyle();
		echo "</head>\n<body>\n";
		$this->displayheader();
		$this->displaymenu($this->button);
		echo $this->content;
		$this->displayfooter();
		}
	public function displaytitle(){
		echo "<title>".$this->title."</title>";
		}
	public function displaykeywords(){
		echo "<meta name=\"keywords\" content=\"".$this->keywords."\">";
		}		
	public function displaystyle(){
		echo "
  <style>
    h1 {
    	color:white; font-size:24pt; text-align:center; 
        font-family:arial,sans-serif
    }
    .menu {
    	color:white; font-size:12pt; text-align:center; 
        font-family:arial,sans-serif; font-weight:bold
    }
    td {	
    	background:black
    }
    p {
    	color:black; font-size:12pt; text-align:justify; 
       	font-family:arial,sans-serif
    }
    p.foot {
    	color:white; font-size:9pt; text-align:center; 
        font-family:arial,sans-serif; font-weight:bold
    }
    a:link,a:visited,a:active {
    	color:white
    }
	.footer {
		bottom:0px;
		position:absolute
	}
  </style>";
		}
	public function displayheader(){
		?>
		<table width="100%" cellpadding="2" cellspacing="0" border="0">
        	<tr bgcolor="#000000">
            	<td align="left"><img src="img/logo.gif" /></td>
                <td><h1>Luhao's Test Web</h1></td>
                <td align="right"><img src="img/logo.gif" /></td>
            </tr>
        </table>
		<?
		}
	public function displaymenu($button){
		echo "<table width=\"100%\" bgcolor=\"#FFFFFF\" cellpadding=\"4\" cellspacing=\"4\">\n<tr>\n";
		
		$width=100/count($button);
		while (list($name,$url)=each($button)){
			$this->displaybutton($width,$name,$url,$this->isurlcurrentpage($url));
			}
		echo"</tr>\n</table>\n";		
		}
	public function isurlcurrentpage($url){//判断是否是当前页面
		if(strpos($_SERVER['PHP_SELF'],$url)==false){
			return false;
			}else{
				return true;
				}
		}
	public function displaybutton($width,$name,$url,$active=false){
		if($active==false){
			echo "<td width=\"".$width."%\"><a href=\"".$url."\"><img src=\"img/s-logo.gif\" border=\"0\" /><span class=\"menu\">".$name."</span></a></td>";
			}elseif($active==true){
				echo "<td width=\"".$width."%\"><img src=\"img/side-logo.gif\" border=\"0\" /><span class=\"menu\">".$name."</span></td>";
				}
		}	
	public function displayfooter(){
		?>
        <table width="100%" bgcolor="black" cellpadding="12" border="0" class="footer">
        <tr>
        <td>
            <p class="foot">&copy; LuHao's WEB.</p>
            <p class="foot">Please see my <a href ="aboutme.html">legal 
            information page</a></p>
        </td>
        </tr>
        </table>
        </body></html>
		<?
		}
					
	}

class page2 extends page{
	public function display(){
		echo "<html>\n<head>\n";
		$this->displaytitle();
		$this->displaykeywords();
		$this->displaystyle();
		echo "</head>\n<body>\n";
		$this->displayheader();
		$this->displaymenu($this->button);
		echo $this->content;
		}
	}
	
?>